using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MP3Flop
{
    public partial class frmProgress : Form
    {
        private delegate void NoParamCallback();

        private int fileCnt = 0;
        private int curCnt = 0;

        public frmProgress()
        {
            InitializeComponent();
        }

        public void Init(int cnt)
        {
            fileCnt = cnt;

            progressBar.Minimum = 0;
            progressBar.Maximum = cnt;
        }

        public void UpdateCnt()
        {
            if (this.progressBar.InvokeRequired) {
                NoParamCallback d = new NoParamCallback(UpdateCnt);
                try {
                    this.Invoke(d);
                }
                catch { }
            } else {
                curCnt++;
                progressBar.Value = curCnt;
                lblProgress.Text = curCnt.ToString() + " of " + fileCnt.ToString() + " (" + Math.Round((double)100.00 * (double)((double)curCnt / (double)fileCnt), 0).ToString() + "%) files read.";
            }
        }

        public void KillForm()
        {
            if (this.InvokeRequired) {
                NoParamCallback d = new NoParamCallback(KillForm);
                this.Invoke(d);
            } else {
                this.Dispose();
            }
        }

        private void frmProgress_Load(object sender, EventArgs e)
        {

        }
    }
}